-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SSAUpdater] Only iterate blocks modified by CheckIfPHIMatches() in RecordMatchingPHIs() #153596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ordMatchingPHIs In #100281, we use `TaggedBlocks` to record blocks modified by `CheckIfPHIMatche()`, so do not need to clear every block in `BlockList` if `CheckIfPHIMatches()` match failed. If `CheckIfPHIMatches()` match succeed, we can reuse `TaggedBlocks` to only record matching PHIs for modified blocks, avoid checking every block in `BlockList` to see if PHITag is set.
@llvm/pr-subscribers-llvm-transforms Author: Mingjie Xu (Enna1) ChangesIn #100281, we use If Full diff: https://github.com/llvm/llvm-project/pull/153596.diff 1 Files Affected:
diff --git a/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h b/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
index 746926e5bee33..52fe3a6f4baf4 100644
--- a/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
+++ b/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
@@ -366,7 +366,7 @@ class SSAUpdaterImpl {
continue;
// Look for an existing PHI.
- FindExistingPHI(Info->BB, BlockList);
+ FindExistingPHI(Info->BB);
if (Info->AvailableVal)
continue;
@@ -412,11 +412,11 @@ class SSAUpdaterImpl {
/// FindExistingPHI - Look through the PHI nodes in a block to see if any of
/// them match what is needed.
- void FindExistingPHI(BlkT *BB, BlockListTy *BlockList) {
+ void FindExistingPHI(BlkT *BB) {
SmallVector<BBInfo *, 20> TaggedBlocks;
for (auto &SomePHI : BB->phis()) {
if (CheckIfPHIMatches(&SomePHI, TaggedBlocks)) {
- RecordMatchingPHIs(BlockList);
+ RecordMatchingPHIs(TaggedBlocks);
break;
}
}
@@ -424,7 +424,7 @@ class SSAUpdaterImpl {
/// CheckIfPHIMatches - Check if a PHI node matches the placement and values
/// in the BBMap.
- bool CheckIfPHIMatches(PhiT *PHI, SmallVectorImpl<BBInfo *> &TaggedBlocks) {
+ bool CheckIfPHIMatches(PhiT *PHI, BlockListTy &TaggedBlocks) {
// Match failed: clear all the PHITag values. Only need to clear visited
// blocks.
auto Cleanup = make_scope_exit([&]() {
@@ -484,15 +484,15 @@ class SSAUpdaterImpl {
/// RecordMatchingPHIs - For each PHI node that matches, record it in both
/// the BBMap and the AvailableVals mapping.
- void RecordMatchingPHIs(BlockListTy *BlockList) {
- for (typename BlockListTy::iterator I = BlockList->begin(),
- E = BlockList->end(); I != E; ++I)
- if (PhiT *PHI = (*I)->PHITag) {
- BlkT *BB = PHI->getParent();
- ValT PHIVal = Traits::GetPHIValue(PHI);
- (*AvailableVals)[BB] = PHIVal;
- BBMap[BB]->AvailableVal = PHIVal;
- }
+ void RecordMatchingPHIs(BlockListTy &TaggedBlocks) {
+ for (BBInfo *Block : TaggedBlocks) {
+ PhiT *PHI = Block->PHITag;
+ assert(PHI && "PHITag didn't set?");
+ BlkT *BB = PHI->getParent();
+ ValT PHIVal = Traits::GetPHIValue(PHI);
+ (*AvailableVals)[BB] = PHIVal;
+ BBMap[BB]->AvailableVal = PHIVal;
+ }
}
};
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/15136 Here is the relevant piece of the build log for the reference
|
In #100281, we use
TaggedBlocks
to record blocks modified byCheckIfPHIMatche()
, so do not need to clear every block inBlockList
ifCheckIfPHIMatches()
match failed.If
CheckIfPHIMatches()
match succeed, we can reuseTaggedBlocks
to only record matching PHIs for modified blocks, avoid checking every block inBlockList
to see ifPHITag
is set.